//
//  main.m
//  OC03_Homework
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"
int main(int argc, const char * argv[]) {
#pragma mark - 作业一
    /*
     截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
     */
    NSString *urlStr = @"20|https://www.baidu.com";
    NSArray *urlArr = [urlStr componentsSeparatedByString:@"|"];
    for (NSString *str in urlArr) {
        NSLog(@"str = %@", str);
    }
    
#pragma mark - 作业二
    /*
     向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
     */
    int num1 = 10;
    float num2 = 10.0;
    double num3 = 3.1415926;
    BOOL result = YES;
    
    NSNumber *number1 = [NSNumber numberWithInt:num1];
    NSNumber *number2 = [NSNumber numberWithFloat:num2];
    NSNumber *number3 = [NSNumber numberWithDouble:num3];
    NSNumber *numberResult = [NSNumber numberWithBool:result];
    
    NSMutableArray *arrayNumber = [NSMutableArray arrayWithObjects:number1, number2, number3, numberResult, nil];
    NSLog(@"%@", arrayNumber);
    
#pragma mark - 作业三
    /*
     实现图书管理系统(BookManager类)：
     使用数组管理所有书籍(Book类)。
     BookManager类属性数组可以添加、删除。
     可以从数组根据书名查找书籍，并修改书籍的价格。
     展示所有书籍清单（书名)
     */
    Book *bookOne = [Book bookWithName:@"西游记" price:20];
    Book *bookTwo = [Book bookWithName:@"红楼梦" price:25];
    Book *bookThree = [Book bookWithName:@"水浒传" price:30];
    Book *bookFour = [Book bookWithName:@"三国演义" price:35];
    
    BookManager *bookManager = [[BookManager alloc] init];
    bookManager.arrayLibrary = [NSMutableArray array];
    
    [bookManager addBook:bookOne];
    [bookManager addBook:bookTwo];
    [bookManager addBook:bookThree];
    [bookManager addBook:bookFour];
    [bookManager removeBook:bookFour];
    [bookManager findBookWithName:@"西游记" changePrice:28];
    [bookManager list];
    
    return 0;
}
